package com.geepi.util;

import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;

/**
 * Servlet Filter implementation class MyFilter
 */
@WebFilter("/MyFilter")
public class MyFilter implements Filter {

    private String charSet= "";

	
	public void destroy() {
	 System.out.println("destory>>>>>>>>");	
	}

	
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
		request.setCharacterEncoding(charSet);
		chain.doFilter(request, response);
		response.setCharacterEncoding(charSet);
	}

	
	public void init(FilterConfig fConfig) throws ServletException {
		charSet = fConfig.getInitParameter("charSet");
		System.out.println("init>>>--filter-->>"+charSet);
		
	}

}
